$(function () {
    $("#page").load("/back/page.html");

})


function updatabyid(id) {
    localStorage.setItem("recruitmentId",id);
    $('#reght').load('/back/recruitment/recruitmentUpdate.html')//刷新一次页面
}


function deletebyid(id) {
    let data=myAjax("/producat/recruitmentDeleteById",{id: id},"post");
    if (data.count==1){
        alert("删除成功");
        findAll();
    } else {
        alert("删除失败");
    }
}

function findAll() {
    let da={
        pageNum:$.trim($("#pageNum").val()),//页数
        pageSize:$.trim($("#pageSize").val()),//条数
        startwages:$.trim($("#startwages").val()),
        endwages:$.trim($("#endwages").val()),
        address:$.trim($("#address").val()),
        phone:$.trim($("#phone").val()),
        position:$.trim($("#position").val()),
        startdate:$.trim($("#sdate").val()),
        enddate:$.trim($("#edate").val()),
        ordbywages:$("#ordbywages").val(),
    };
    let data=myAjax("/producat/recruitmentFindllTh",da,"get");
    setData(data.list);
    $("#pageCount").html(data.number);
}
function setData(data) {
    let html='';
    for (let i=0;i<data.length;i++){
        html +='   <tr>\n' +//字符串拼接
            '            <td>'+data[i].id+'</td>\n' +
            '            <td>'+data[i].date+'</td>\n' +
            '            <td><div class="biaos"> '+data[i].introduction+'</div></td>\n' +
            '            <td>'+data[i].wages+'</td>\n' +
            '            <td>'+data[i].address+'</td>\n' +
            '            <td>'+data[i].phone+'</td>\n' +
            '            <td>'+data[i].mailbox+'</td>\n' +
            '            <td>'+data[i].position+'</td>\n' +
            '            <td><input type="button" value="编辑" onclick="updatabyid('+data[i].id+')"> <a href="javascript:deletebyid('+data[i].id+')">删除</a></td>\n' +
            '        </tr>';
    }
    $("#recruitmentFindAll").html(html);
}


// function ordBy() {
//     let da={
//         ordbywages:$("#ordbywages").val(),
//     };
//     let data=myAjax("/back/recruitment/ordBywages",da,"get");
//     data=data.list;
//     let html='';
//     for (let i=0;i<data.length;i++){
//         html +='   <tr>\n' +//字符串拼接
//             '            <td>'+data[i].id+'</td>\n' +
//             '            <td>'+data[i].introduction+'</td>\n' +
//             '            <td>'+data[i].wages+'</td>\n' +
//             '            <td>'+data[i].address+'</td>\n' +
//             '            <td>'+data[i].phone+'</td>\n' +
//             '            <td>'+data[i].mailbox+'</td>\n' +
//             '            <td>'+data[i].position+'</td>\n' +
//             '            <td><input type="button" value="编辑" onclick="updatabyid('+data[i].id+')"> <a href="javascript:deletebyid('+data[i].id+')">删除</a></td>\n' +
//             '        </tr>';
//     }
//     $("#recruitmentFindAll").html(html);//对当前tbody进行赋值
// }